import javax.sound.midi.MidiChannel;


public class PlayNote implements Runnable {

	MidiChannel channel;
	Note note;
	int sleepIntervalForCurrentTempo;
	
	public PlayNote(MidiChannel channel, Note note, int sleepIntervalForCurrentTempo)
	{
		this.channel = channel;
		this.note = note;
		this.sleepIntervalForCurrentTempo = sleepIntervalForCurrentTempo;
	}
	
    public void run() {
    	channel.noteOn( note.getPitch(), note.getVelocity());
		try
		{
			Thread.sleep( (long) (note.getDuration()*sleepIntervalForCurrentTempo) ); 
		}
		catch
		( InterruptedException e ) 
		{ 
			
		}
		channel.noteOff( note.getPitch() );
    }
}